package com.anhtuan.reminder.services;

import com.anhtuan.reminder.tasks.DoActionTask;

import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
//import android.util.Log;

public class NotifyService extends Service{

	private final IBinder binder = new ServiceBinder();
	
	public static final String INTENT_START = "com.anhtuan.reminder.services.INTENT_START";
	public static final String INTENT_STOP = "com.anhtuan.reminder.services.INTENT_STOP";
	public static final String INTENT_TASK_ID = "taskId";
	
	@Override
	public int onStartCommand(Intent intent, int flags, int startId) {

		if (intent.getBooleanExtra(INTENT_START, false) == true) {
			
			new DoActionTask(this, intent.getIntExtra(INTENT_TASK_ID, -1)).execute();
			
		}
		
		return START_NOT_STICKY;
	}
	
	@Override
	public IBinder onBind(Intent intent) {
		return binder;
	}

	// Class for client to access
	public class ServiceBinder extends Binder {
		NotifyService getService() {
			return NotifyService.this;
		}
	}
}
